package com.bcn.login_mybatisplus_demo.saraca.controller;

import com.bcn.login_mybatisplus_demo.common.controller.BaseController;
import com.bcn.login_mybatisplus_demo.common.page.TableDataInfo;
import com.bcn.login_mybatisplus_demo.interceptor.AuthStorage;
import com.bcn.login_mybatisplus_demo.pojo.vo.R;
import com.bcn.login_mybatisplus_demo.saraca.pojo.AppUser;
import com.bcn.login_mybatisplus_demo.saraca.service.IAppUserService;
import com.bcn.login_mybatisplus_demo.saraca.vo.AppUserVo;
import com.bcn.login_mybatisplus_demo.schedule.domain.TAppSchedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * app用户Controller
 * 
 * @author ruoyi
 * @date 2025-02-28
 */
@RestController
@RequestMapping("/app/user")
public class AppUserController extends BaseController
{
    @Autowired
    private IAppUserService appUserService;

    /**
     * 查询app用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppUser appUser)
    {
        startPage();
        List<AppUser> list = appUserService.selectAppUserList(appUser);
        return getDataTable(list);
    }

    /**
     * 获取app用户详细信息
     */
    @PostMapping("/getOne")
    public R getInfo()
    {
        Long id = AuthStorage.getUser().getId();
        return R.success(appUserService.selectAppUserById(id));
    }

    /**
     * 修改保存用户信息
     */

    /**
     * 修改保存【请填写功能名称】
     */
    @PostMapping("/edit")
    public R editSave(@RequestBody AppUser appUser)
    {
        return R.success(appUserService.updateAppUser(appUser));
    }



    /**
     * 新增app用户
     */
    @PostMapping("/register")
    public R add(@RequestBody AppUser appUser)
    {
        return appUserService.insertAppUser(appUser);
    }

    /**
     * 登录用户
     */
    @PostMapping("/login")
    public R login(@RequestBody AppUser appUser)
    {
        return appUserService.login(appUser);
    }


}
